/*
 *说明：工单表 增加/修改脚本
 *
 *@author mlc 2013-04-07
*/

var opeForm;
var operationType;

$(function(){

	opeForm=$('#opeForm');
	operationType = $('#operationType').val();

	if (operationType == 0) {
		opeForm.url = 'P_WF_ORDER!doInsert.do';

	} else if(operationType == 1){
		opeForm.url = 'P_WF_ORDER!doUpdate.do';

	} 

	$('#okBtn').click(doOk);
	$('#cancelBtn').click(closeWin);
});

//保存按钮操作
function doOk() {

	var validateResult = opeForm.form('validate');

	if (!validateResult){
		showInfoWin('请正确填写信息!');
		return;
	}

	var options = { 
		url: opeForm.url,
		type: 'post',
		success: function(data){
			getOpenerWin().afterOK();

		    if (operationType == '0') {
				showInfoWin('操作成功!', refreshWin);

			} else {
				showInfoWin('操作成功!', function() {window.close();});
			}
		}
	};

	opeForm.ajaxSubmit(options);
}
